//
//  TurnOverBalanceTableViewController.m
//  EasyToTesco2.0
//
//  Created by 袖手旁觀 on 16/6/23.
//  Copyright © 2016年 EasyToTesco. All rights reserved.
//

#import "TurnOverBalanceTableViewController.h"
#import "FirstBalanceTableViewCell.h"
#import "FirstCellTableViewCell.h"
#import "LastBalanceTableViewCell.h"
#import "SMSelectView.h"

@interface TurnOverBalanceTableViewController ()<didClickImmediatePayButtonDelegate,UITextFieldDelegate>

@property (nonatomic,strong)NSArray *secondCellArray;

@property (nonatomic,strong)UITextField *inputTextField;

@property (nonatomic,strong)NSDictionary *userInfoData;

@property(nonatomic,strong) NSArray       *rateArray;
@property(nonatomic,strong) NSArray       *dayArray;
@property(nonatomic,strong) MBProgressHUD *progressHUD;
@property(nonatomic,strong) UILabel       *realMoney;
@property(nonatomic,strong) UILabel       *feilvLabel;
@property(nonatomic,strong) UILabel       *rateCycle;
@property(nonatomic,strong) NSString      *amount_ceiling;

@property(nonatomic,assign) NSInteger     defaultIndex;
@property(nonatomic,assign) BOOL          isOpenRate;  //根据api判断有误费率 ture为有

@end

static NSString *const firstBalanceReuseIdentifier = @"firstBalance";

static NSString *const secondBalanceReuseIdentifier = @"secondBalance";

static NSString *const lastFirstReuseIdentifier = @"lastFirst";

static NSString *const lastImmediatePayIdentifier = @"ImmediatePay";

@implementation TurnOverBalanceTableViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = BACKGROUND_COLOR;
    self.tableView.backgroundColor = BACKGROUND_COLOR;
    //    self.tableView.tableFooterView = [[UIView alloc] init];
    
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.edgesForExtendedLayout = UIRectEdgeNone;
    self.title = @"营业额结算";
    //
    [self loadData];
    
    _defaultIndex = 0;
    
}


- (void)loadData
{
    _progressHUD = [MBProgressHUD show:self.view andMessage:nil];
    [self.view addSubview:_progressHUD];
    
    
    dispatch_group_t group = dispatch_group_create();
    
    dispatch_group_async(group, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        
        dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
        
        [[NetWorkSharedTools sharedNetWorkTools] objectWithURLDict:@{@"username":USERNAME} AndMenthodName:@"api/User/info" completeBlock:^(id object) {
            NSLog(@"%@",object);
            self.userInfoData = [object objectForKey:@"data"];
            self.amount_ceiling = self.userInfoData[@"amount_ceiling"];
            [self.tableView reloadData];
            
            dispatch_semaphore_signal(semaphore);
        }];
        
        dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
        
    });
    
    dispatch_group_async(group, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        
        dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
        
        [[NetWorkSharedTools sharedNetWorkTools] objectWithURLDict:@{@"username":USERNAME} AndMenthodName:@"/api/Cooperation/turnoverClearingRate" completeBlock:^(id object) {
            
            NSLog(@"%@",object);
            
            
            if (JudgeBackDataCode) {
                _isOpenRate = true;
                NSDictionary *dataDict = [object objectForKey:@"data"];
                self.rateArray =  [dataDict objectForKey:@"rate"];
                self.dayArray =   [dataDict objectForKey:@"day"];
                NSLog(@"%@",_rateArray);
            }else if ([[object objectForKey:@"code"] isEqual:@(-2)]){ // 关闭费率
                
                _isOpenRate = false;
                
            }else{
                NSDictionary *message = [object objectForKey:@"message"];
                MBProgressHUD *hud = [MBProgressHUD showMessage:[NSString stringWithFormat:@"%@",message[@"view"]] toView:self.view dimBackground:NO AndCompleteBlock:nil];
                [self.view addSubview:hud];
            }
            
            [self.tableView reloadData];
            dispatch_semaphore_signal(semaphore);
        }];
        
        dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
        
    });
    
    dispatch_group_notify(group, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        NSLog(@"完成了网络请求");
        
    });
    
    [_progressHUD hide:true];
}


- (void)didClickImmediatePayButton {
    
    if (self.inputTextField.text.integerValue > [self.amount_ceiling integerValue]) {
        MBProgressHUD *hud = [MBProgressHUD showMessage:[NSString stringWithFormat:@"派现金额不得高于%@",self.amount_ceiling] toView:self.view dimBackground:NO AndCompleteBlock:^(id object) {
            self.inputTextField.text = nil;
        }];
        [self.view addSubview:hud];
        
        return;
    }
    
    
    NSString *rate = nil;
    if (_isOpenRate) {
        rate = self.rateArray[_defaultIndex];
    }else{
        rate = @"0.00";
    }
    
    NSDictionary *params = @{
                             @"username":USERNAME,
                             @"jine":self.inputTextField.text,
                             @"rate":rate
                             };
    NSLog(@"%@",params);
    [[NetWorkSharedTools sharedNetWorkTools] objectWithURLDict:params AndMenthodName:@"/api/Cooperation/newTurnoverClearing" completeBlock:^(id object) {
        
        if (JudgeBackDataCode) {
            
            MBProgressHUD *hud = [MBProgressHUD showMessage:@"营业额结算成功" toView:self.view dimBackground:NO AndCompleteBlock:^(id object) {
                self.inputTextField.text = nil;
            }];
            
            [self.view addSubview:hud];
            
        } else {
            NSString *message = [object[@"message"] objectForKey:@"view"];
            
            MBProgressHUD *hud = [MBProgressHUD showMessage:message toView:self.view dimBackground:NO AndCompleteBlock:nil];
            
            [self.view addSubview:hud];
        }
        
    }];
}



#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    
    if (_isOpenRate) {
        return 4;
    }else{
        return 3;
    }
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    if(section == 0) {
        return 1;
    } else if(section == 1) {
        return 6;
    }else{
        return 1;
    }
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    
    if (indexPath.section == 0) {
        
        FirstBalanceTableViewCell *firstBalance = [tableView dequeueReusableCellWithIdentifier:firstBalanceReuseIdentifier];
        
        if (!firstBalance) {
            firstBalance = [[FirstBalanceTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:firstBalanceReuseIdentifier];
            
            firstBalance.selectionStyle = UITableViewCellSelectionStyleNone;
        }
        
        firstBalance.nameLabel.text = USERNAME;
        return firstBalance;
        
    }else if(indexPath.section == 1){
        
        if (indexPath.row < 5) {
            
            
            FirstCellTableViewCell *secondCell = [tableView dequeueReusableCellWithIdentifier:secondBalanceReuseIdentifier];
            
            if (!secondCell) {
                secondCell = [[FirstCellTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:secondBalanceReuseIdentifier];
                
                secondCell.selectionStyle = UITableViewCellSelectionStyleNone;
                
                secondCell.rightLabel.hidden = NO;
                secondCell.inPutTextField.hidden = YES;
                //secondCell.rightLabel.textColor = [UIColor blackColor];
            }
            
            secondCell.firstLabel.text = self.secondCellArray[indexPath.row];
            
            switch (indexPath.row) {
                case 0:
                    secondCell.rightLabel.text = [self loadBANKWeithNum: [[self.userInfoData objectForKey:@"yinhang"]integerValue]];
                    break;
                    
                case 1:
                    secondCell.rightLabel.text = [self.userInfoData objectForKey:@"xingming"];
                    break;
                    
                case 2:
                    secondCell.rightLabel.text = [self.userInfoData objectForKey:@"kaihuhang"];
                    break;
                    
                case 3:
                    
                {
                    NSString *str = [self.userInfoData objectForKey:@"zhanghao"];
                    if ([str length] >0) {
                        secondCell.rightLabel.text = [NSString stringWithFormat:@"**** %@",[self loadBankLastFourNum:[self.userInfoData objectForKey:@"zhanghao"]]];
                    }else{
                        
                        secondCell.rightLabel.text = @"未绑定银行卡";
                    }
                }
                    
                    break;
                    
                case 4:
                    secondCell.rightLabel.text = [NSString stringWithFormat:@"%@",[self.userInfoData objectForKey:@"yyye"]];
                    break;
                    
                    
                    
                default:
                    break;
            }
            
            //        secondCell.rightLabel.text = [self.secondCellArray[indexPath.row] objectForKey:@"right"];
            
            return secondCell;
            
            
        }else{
            
            FirstCellTableViewCell *lastFirst = [tableView dequeueReusableCellWithIdentifier:lastFirstReuseIdentifier];
            
            if (!lastFirst) {
                lastFirst = [[FirstCellTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:lastFirstReuseIdentifier];
                
                lastFirst.selectionStyle = UITableViewCellSelectionStyleNone;
            }
            
            lastFirst.firstLabel.text = @"派现金额";
            
            lastFirst.inPutTextField.tag = 101;
            lastFirst.inPutTextField.delegate = self;
            lastFirst.inPutTextField.placeholder = @"请输入金额";
            lastFirst.inPutTextField.keyboardType = UIKeyboardTypeNumberPad;
            [lastFirst.inPutTextField addTarget:self action:@selector(didClickLastTextField:) forControlEvents:UIControlEventEditingChanged];
            self.inputTextField = lastFirst.inPutTextField;
            
            return lastFirst;
        }
    }else{
        
        if (_isOpenRate) {
            
            if (indexPath.section == 2) {
                
                UITableViewCell *cell = [[UITableViewCell alloc] initWithFrame:CGRectMake(0,0,WIDTH,44)];
                cell.selectionStyle = UITableViewCellSelectionStyleNone;
                [cell addSubview:[self rateView]];
                return cell;
            }else {
                
                UITableViewCell *cell = [[UITableViewCell alloc] initWithFrame:CGRectMake(0,0,WIDTH,HEIGHT - 458)];
                cell.selectionStyle = UITableViewCellSelectionStyleNone;
                [cell addSubview:[self lastView]];
                return cell;
                
            }
        }else{
            
            UITableViewCell *cell = [[UITableViewCell alloc] initWithFrame:CGRectMake(0,0,WIDTH,HEIGHT - 406)];
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            [cell addSubview:[self lastView]];
            return cell;
            
        }
        
        
    }
}
//
- (void)didClickLastTextField:(UITextField *)textField {
    if (textField == self.inputTextField) {
        NSLog(@"%@",textField.text);
        if (textField.text.integerValue >= [self.amount_ceiling integerValue]) {
            textField.text = self.amount_ceiling;
        }
    }
}

- (void)textFieldDidEndEditing:(UITextField *)textField
{
    if (textField == self.inputTextField) {
        
        
        
        
        if (textField.text.integerValue >= [self.amount_ceiling integerValue]) {
            textField.text = self.amount_ceiling;
        }else{
            textField.text = self.inputTextField.text;
        }
        
        if (_isOpenRate) {
            
            _realMoney.text = [NSString stringWithFormat:@"%.3f",[self.inputTextField.text floatValue]*(1-[self.rateArray[_defaultIndex] floatValue])];
            
            //手续费
            NSString *str = [NSString stringWithFormat:@"%.3f",[self.inputTextField.text floatValue] * [self.rateArray[_defaultIndex] floatValue]];
            
            NSString *str1 = @"%";
            _feilvLabel.text = [NSString stringWithFormat:@"%@ 费率:%.1f%@",
                                str,
                                [self.rateArray[_defaultIndex] floatValue] *100,
                                str1];
            
        }else{
            
            _realMoney.text = [NSString stringWithFormat:@"%.3f",[self.inputTextField.text floatValue]];
            _feilvLabel.text = @"0.00";
            
        }
    }
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [self.inputTextField resignFirstResponder];
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    
    if (indexPath.section == 0) {
        return 70;
    }else if (indexPath.section == 1){
        return 44;
    }else{
        
        if (_isOpenRate) {
            
            if (indexPath.section == 2) {
                return 44;
            }else{
                return HEIGHT - 458;
            }
        }else{
            return HEIGHT - 406;
        }
    }
}


- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    if (section == 0) {
        return 0.001;
    } else {
        return 8;
    }
}


- (void)didClickImmediatePayButton:(UIButton *)immediatePayButton {
    [self.inputTextField resignFirstResponder];
    
    
    if (self.inputTextField.text.length == 0) {
        
        MBProgressHUD *hud = [MBProgressHUD showMessage:@"请输入金额" toView:self.view dimBackground:NO AndCompleteBlock:^(id object) {
            [self.inputTextField becomeFirstResponder];
        }];
        
        [self.view addSubview:hud];
        
    } else {
        [self didClickImmediatePayButton];
    }
}

- (NSString *)loadBANKWeithNum:(NSInteger)BankNum {
    switch (BankNum) {
        case 1:
            return @"中国农业银行";
            break;
            
        case 2:
            return @"中国工商银行";
            break;
            
        case 3:
            return @"中国建设银行";
            break;
            
        case 4:
            return @"中国银行";
            break;
            
        case 5:
            return @"交通银行";
            break;
            
        case 6:
            return @"招商银行";
            break;
            
        case 7:
            return @"中国民生银行";
            
        default:
            break;
    }
    return @"请确认开户银行";
}

- (NSString *)loadBankLastFourNum:(NSString *)string {
    
    NSLog(@"%@",string);
    NSInteger length = [string length];
    
    NSString *lastString = [string substringWithRange:NSMakeRange(length - 4, 4)];
    NSLog(@"%@",lastString);
    
    return lastString;
    
}


- (void)haveRateClick
{
    [self.inputTextField resignFirstResponder];
    
    if (self.rateArray.count != self.dayArray.count) {
        return; // 费率和到账时间一一 对应.怕崩掉
    }
    
    NSMutableArray *array = [NSMutableArray array];
    for (int i = 0; i < self.rateArray.count; ++i) {
        
        NSString *str  = @"%";
        NSString *rate = [NSString stringWithFormat:@"%@到账时间%@个工作日 手续费%.1f%@",
                          self.dayArray[i],
                          self.dayArray[i],
                          [self.rateArray[i] floatValue] * 100,
                          str];
        [array addObject:rate];
    }
    //    NSLog(@"%@",array);
    [SMSelectView showWithTitle:@"提现周期方式" options:array delegate:self completionHandler:^(NSInteger index) {
        NSLog(@"SMSelectView:%ld",index);
        _defaultIndex = index;
        self.rateCycle.text = array[index];
        
        //如果已输入数额 联动
        _realMoney.text = [NSString stringWithFormat:@"%.3f",[self.inputTextField.text floatValue]*(1-[self.rateArray[_defaultIndex] floatValue])];
        
        //手续费
        NSString *str = [NSString stringWithFormat:@"%.3f",[self.inputTextField.text floatValue] * [self.rateArray[_defaultIndex] floatValue]];
        
        NSString *str1 = @"%";
        _feilvLabel.text = [NSString stringWithFormat:@"%@ 费率:%.1f%@",
                            str,
                            [self.rateArray[_defaultIndex] floatValue] *100,
                            str1];
        
        
    }];
}

- (UIView *)rateView
{
    UIView *rateView = [[UIView alloc] initWithFrame:CGRectMake(0,0,WIDTH,44)];
    
    UILabel *rateLabeL = [[UILabel alloc] init];
    rateLabeL.text = @"提现周期";
    [rateView addSubview:rateLabeL];
    rateLabeL.font = FONT(14);
    
    CGFloat leftM = 17;
    [rateLabeL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(rateView).offset(leftM);
        make.top.equalTo(rateView).offset(10);
        make.height.mas_equalTo(25);
    }];
    
    
    _rateCycle = [[UILabel alloc] init];
    _rateCycle.font = BOLDFONT(14);
    _rateCycle.textColor = DEFAULT_COLOR;
    [rateView addSubview:_rateCycle];
    [_rateCycle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(rateLabeL.mas_right).offset(10);
        make.centerY.equalTo(rateLabeL);
        make.height.mas_equalTo(25);
    }];
    
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(haveRateClick)];
    [_rateCycle addGestureRecognizer:tap];
    
    
    if (_isOpenRate) {
        
        NSString *str = @"%";
        _rateCycle.text = [NSString stringWithFormat:@"%@到账时间%@个工作日 手续费%.1f%@",
                           self.dayArray[_defaultIndex],
                           self.dayArray[_defaultIndex],
                           [self.rateArray[_defaultIndex] floatValue] * 100,
                           str];
        _rateCycle.userInteractionEnabled = true;
        
    }else{
        _rateCycle.text = @"T+0到账时间0个工作日 手续费0%";
        _rateCycle.userInteractionEnabled = false;
    }
    
    
    UIButton *guide = [[UIButton alloc] init];
    [guide setImage:[UIImage imageNamed:@"rate_guide"] forState:UIControlStateNormal];
    [rateView addSubview:guide];
    [[guide rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(id x) {
        [self haveRateClick];
    }];
    
    [guide mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(rateLabeL);
        make.right.equalTo(rateView.mas_right).offset(-10);
        make.width.height.mas_equalTo(20);
    }];
    
    
    return rateView;
}


- (UIView *)lastView
{
    UIView *content = [[UIView alloc] initWithFrame:CGRectMake(0,0,WIDTH,HEIGHT-458)];
    content.backgroundColor = [UIColor whiteColor];
    
    UILabel *real = [[UILabel alloc] init];
    [content addSubview:real];
    real.font = FONT(14);
    real.text = @"实际到账 : ";
    
    [real mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(content.mas_left).offset(17);
        make.top.equalTo(content.mas_top).offset(10);
    }];
    
    
    _realMoney = [[UILabel alloc] init];
    _realMoney.font= FONT(15);
    _realMoney.text = @"0.00";
    _realMoney.textColor = DEFAULT_COLOR;
    [content addSubview:_realMoney];
    [_realMoney mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(real.mas_right).offset(0);
        make.centerY.equalTo(real);
    }];
    
    
    UILabel *feilv = [[UILabel alloc] init];
    [content addSubview:feilv];
    feilv.font = FONT(14);
    feilv.text = @"手续费 : ";
    [feilv mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_realMoney.mas_right).offset(10);
        make.centerY.equalTo(real);
    }];
    
    
    _feilvLabel = [[UILabel alloc] init];
    _feilvLabel.font= FONT(15);
    _feilvLabel.text = @"0.00(费率:0.0%)";
    _feilvLabel.textColor = DEFAULT_COLOR;
    [content addSubview:_feilvLabel];
    [_feilvLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(feilv.mas_right).offset(0);
        make.centerY.equalTo(real);
    }];
    
    
    
    UILabel *moreLabel = [[UILabel alloc] init];
    moreLabel.textColor = DEFAULT_COLOR;
    moreLabel.numberOfLines = 0;
    moreLabel.font = [UIFont systemFontOfSize:13];
    [content addSubview:moreLabel];
    
    if (self.userInfoData.allKeys >0) {
        moreLabel.text = [NSString stringWithFormat:@"注:派现金额不得超过 %@,节假日顺延,请确保卡号无误",self.amount_ceiling];
    }
    
    
    if (!_isOpenRate) {
        _feilvLabel.hidden = true;
        feilv.hidden = true;
        _realMoney.hidden = true;
        real.hidden = true;
        
        [moreLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(real);
            make.width.mas_equalTo(WIDTH - 17*2);
            make.top.equalTo(content.mas_top).offset(10);
        }];
        
    }else{
        
        [moreLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(real);
            make.width.mas_equalTo(WIDTH - 17*2);
            make.top.equalTo(real.mas_bottom).offset(10);
        }];
    }
    
    
    UIButton * immediatePay = [[UIButton alloc] init];
    [immediatePay setTitle:@"立即申请" forState:UIControlStateNormal];
    immediatePay.backgroundColor = DEFAULT_COLOR;
    immediatePay.titleLabel.font = FONT(15);
    [immediatePay setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    immediatePay.layer.cornerRadius = 5;
    immediatePay.layer.masksToBounds = YES;
    [immediatePay addTarget:self action:@selector(didClickImmediatePayButton:) forControlEvents:UIControlEventTouchUpInside];
    [content addSubview:immediatePay];
    
    [immediatePay mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(moreLabel.mas_bottom).with.offset(15);
        make.centerX.equalTo(content.mas_centerX);
        make.width.mas_equalTo(WIDTH-17 *2);
        make.height.mas_equalTo(40);
    }];
    
    return content;
}





- (NSDictionary *)userInfoData {
    if (!_userInfoData) {
        _userInfoData = [NSDictionary dictionary];
    }
    return _userInfoData;
}

- (NSArray *)rateArray
{
    if (!_rateArray ) {
        _rateArray = [[NSArray alloc] init];
    }
    return _rateArray;
}

- (NSArray *)dayArray
{
    if (!_dayArray ) {
        _dayArray = [[NSArray alloc] init];
    }
    return _dayArray;
}


- (NSArray *)secondCellArray {
    if (!_secondCellArray) {
        _secondCellArray = @[
                             @"所属银行",
                             @"真实姓名",
                             @"开户行",
                             @"银行卡尾号",
                             @"营业账户余额"
                             ];
        
    }
    return _secondCellArray;
}



//- (void)loadUserInfoData {
//
//    [[NetWorkSharedTools sharedNetWorkTools] objectWithURLDict:@{@"username":USERNAME} AndMenthodName:@"api/User/info" completeBlock:^(id object) {
//        NSLog(@"%@",object);
//        self.userInfoData = [object objectForKey:@"data"];
//        //        [self.tableView reloadData];
//    }];
//
//
//}
//
//- (void)getTurnoverClearingRate
//{
//    _progressHUD = [MBProgressHUD show:self.view andMessage:nil];
//    [self.view addSubview:_progressHUD];
//
//    kW_DISPATCH_GLOBAL_QUEUE_DEFAULT((^{
//
//        [[NetWorkSharedTools sharedNetWorkTools] objectWithURLDict:@{@"username":USERNAME} AndMenthodName:@"/api/Cooperation/turnoverClearingRate" completeBlock:^(id object) {
//
//            NSLog(@"%@",object);
//
//            kW_DISPATCH_MAIN_THREAD((^{
//
//                if (JudgeBackDataCode) {
//                    _isOpenRate = true;
//                    NSDictionary *dataDict = [object objectForKey:@"data"];
//                    self.rateArray =  [dataDict objectForKey:@"rate"];
//                    self.dayArray =   [dataDict objectForKey:@"day"];
//                    NSLog(@"%@",_rateArray);
//                }else if ([[object objectForKey:@"code"] isEqual:@(-2)]){ // 关闭费率
//
//                    _isOpenRate = false;
//
//                }else{
//                    NSDictionary *message = [object objectForKey:@"message"];
//                    MBProgressHUD *hud = [MBProgressHUD showMessage:[NSString stringWithFormat:@"%@",message[@"view"]] toView:self.view dimBackground:NO AndCompleteBlock:nil];
//                    [self.view addSubview:hud];
//                }
//
//                [self.tableView reloadData];
//            }));
//        }];
//    }));
//
//
//    [_progressHUD hide:true];
//
//}


@end
